﻿/********************************************************************************
 * Copyright (C) 2020 - All Rights Reserved by xiaomutech
 * date: 2020/8/3
 * file: %filename%
 * auth: yhni lynnhua@163.com QQ:393320854
 * desc:
 ********************************************************************************/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "sqlhelper.h"

#include <QMainWindow>

#include <QDebug>
#include <QMessageBox>
#include <QTimerEvent>
#include <QDateTime>
#include <QInputDialog>
#include <QLineEdit>
#include <QCheckBox>
#include <QWidget>
#include <QVBoxLayout>
#include <QScrollArea>
#include <QEvent>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
private:
    Ui::MainWindow *ui;
    int m_nTimerId;
    QVBoxLayout *vbox;
    SQLHelper *sqlHelper;
    QSqlDatabase db ;
    QDate picked;

protected:
    // 设置数据库名称和连接名称
    QString dbFileName = "/home/yzp/git/kylin-learn/myCalender/mydb.sqlite";
    QString connectionName = "eventConnection";

    void timerEvent(QTimerEvent *e);
    //void mousePressEvent(QMouseEvent *e);
    void insertCheckBox(const QString& eventId, const QString &text, bool checked);
    void loadEvents(const QDate& date, bool checked);

    void updateDatabaseStatus(const QString& eventId, int status);

private slots:
    void on_btnCurrendDate_clicked();
    void on_lineEdit_returnPressed();
    void handleSelectedDateChanged(const QDate& date);
};
#endif // MAINWINDOW_H
